<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />
	<title>报价信息</title>
	<link href="css/mui.min.css" rel="stylesheet"/>
	<link href="css/previewImage.css" rel="stylesheet"/>
	<link href="css/common.css" rel="stylesheet"/>
	<script src="js/mui.min.js"></script>
    <script src="js/mui.zoom.js"></script>
    <script src="js/mui.previewimage.js"></script>
	<script type="text/javascript" charset="utf-8">
        mui.init();
	</script>
</head>
<body>
<header class="mui-bar mui-bar-nav" style="padding-right: 15px;">
	<h1 class="mui-title">保单信息-报价信息</h1>
	<button class="mui-btn mui-btn-blue mui-btn-link mui-pull-right" onclick="window.history.go(-1);">返回</button>
</header>
<div class="mui-content">
	<div>
		<ul class="mui-table-view">
			<li class="mui-table-view-cell">
				订单信息
			</li>
			<li class="mui-table-view-cell">
				<div class="mui-table">
					<div class="mui-table-cell mui-col-xs-10" id="payInfo">
					</div>
				</div>
			</li>
		</ul>
		<ul class="mui-table-view" style="margin-top: 10px;">
			<li class="mui-table-view-cell">
				付款信息
			</li>
			<li class="mui-table-view-cell">
				<table width="100%">
					<tr>
						<td width="70%" id="companyCode"></td>
						<td align="right" id="orderQuotedPrice"></td>
					</tr>
				</table>
			</li>
			<li class="mui-table-view-cell">
				<table width="100%">
					<tr>
						<td width="25%"><h5>推荐指数：</h5></td>
						<td align="right" id="recommendGrade"></td>
					</tr>
					<tr>
						<td><h5>交强险期限：</h5></td>
						<td align="right"><h5 id="ctaliTime"></h5></td>
					</tr>
					<tr>
						<td><h5>商业险期限：</h5></td>
						<td align="right"><h5 id="businessTime"></h5></td>
					</tr>
					<tr>
						<td><h5>报价明细：</h5></td>
						<td align="right"></td>
					</tr>
					<tr>
                        <td colspan="2" id="attachment" align="center">
						</td>
					</tr>
				</table>
				<div class="mui-content-padded">
					<button type="button" class="mui-btn mui-btn-primary mui-btn-block" id="patchBtn" data-loading-icon="mui-spinner mui-spinner-white" data-loading-text="提交中...">确认报价</button>
				</div>
			</li>
		</ul>
	</div>
</div>
<footer></footer>
</body>
<script src="js/jquery.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="js/wxOpen.js"></script>
<script src="js/common.js"></script>
<script>
mui.previewImage();

$(function () {
    var orderCode = GetQueryString("orderCode"),
        consumerType = GetQueryString("consumerType"),
        consumerName = GetQueryString("consumerName"),
        consumerIdCard = GetQueryString("consumerIdCard"),
        enterpriseName = GetQueryString("enterpriseName"),
        enterpriseLicence = GetQueryString("enterpriseLicence"),
        wxOrderStatusText = GetQueryString("wxOrderStatusText"),
        applyTime = GetQueryString("applyTime"),
        auditingTime = GetQueryString("auditingTime"),
        signTime = GetQueryString("signTime");

    var payResult = "";
    if(consumerType == "GR"){
        payResult += '<h5>车主姓名：'+ consumerName +'</h5>';
        payResult += '<h5>身份证号：'+ consumerIdCard +'</h5>';
    }else if(consumerType == "QY"){
        payResult += '<h5>企业名称：'+ enterpriseName +'</h5>';
        payResult += '<h5>营业证号：'+ enterpriseLicence +'</h5>';
    }
    payResult += '<h5>申请进度：<span style="color: #ff0000;">'+ wxOrderStatusText +'</span></h5>';
    payResult += '<h5>申请时间：'+ applyTime +'</h5>';
    payResult += '<h5 style="display: none">审核时间：'+ auditingTime +'</h5>';
    payResult += '<h5 style="display: none">签约日期：'+ signTime +'</h5>';
    $("#payInfo").append(payResult);

    //报价信息-付款信息
    $.ajax({
        type: 'POST',
        url: url +'weixinOrder/getOrdePatchInfo',
        data:{
            "openId":openId,
            "orderCode":orderCode
        },
        dataType: 'json',
        success: function (data) {
            console.log(data);
            if (data.repCode == "000000") {
                $("#companyCode").html('<img src="images/icon_' + data.data.companyCode + '.png" width="30" style="vertical-align:middle;" /> ' + companyCodeConvert(data.data.companyCode));
                $("#orderQuotedPrice").html(data.data.orderQuotedPrice + "/年");
                $("#ctaliTime").html(data.data.ctaliStartTime +" 至 "+ data.data.ctaliEndTime);
                $("#businessTime").html(data.data.businessStartTime +" 至 "+ data.data.businessEndTime);
                for(var s=0; s<data.data.recommendGrade; s++){
                    $("#recommendGrade").append('<img src="images/icon_star.png" width="20"/>');
                }
                if(data.data.recommendGrade<5){
                    for(var g=0; g<5-(data.data.recommendGrade); g++){
                        $("#recommendGrade").append('<img src="images/icon_star_gray.png" width="20"/>');
                    }
                }

                var s = data.data.attachmentIds;
                var ss = s.split(",");
                if(ss.length > 0){
                    for(var i=0; i<ss.length; i++){
                        $("#attachment").prepend('<img src="' + url + 'weixinFile/getImg?id='+ ss[i] +'" width="70%" data-preview-src="" data-preview-group="1"/>');
                    }
                }
            }else if(data.repCode == "999999") {
                mui.toast("获取付款信息失败");
            }
        },
        error: function () {
            mui.toast("error");
        }
    });


    //报价信息提交
    mui(document.body).on('tap', '#patchBtn', function(e) {
    //$("#patchBtn").click(function () {
        mui(this).button('loading');
        $.ajax({
            type: 'POST',
            url: url +'weixinOrder/ordeOfferSubmit',
            data:{
                "openId":openId,
                "orderCode":orderCode
            },
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.repCode == "000000") {
                    mui.toast("提交成功");
                    var setUrl = "ip_my_apply.html?openId=" + openId;
                    setTimeout("window.location.href='"+setUrl+"'", 1000);
                }else if(data.repCode == "999999") {
                    mui('#ordePatchBtn').button('reset');
                    mui.toast("提交失败");
                }
            },
            error: function () {
                mui('#ordePatchBtn').button('reset');
                mui.toast("error");
            }
        });
    });
});
</script>
</html>